import {reqGoodsInfo} from '@/api'

const actions = {
	async getGoodsInfo({commit},searchParams){
		const result = await reqGoodsInfo(searchParams)
		if(result.code === 200){
			commit('SAVE_GOODS_INFO',result.data)
		}else{
			alert(result.message)
		}
	}
}

const mutations = {
	SAVE_GOODS_INFO(state,info){
		state.goodsInfo = info
	}
}

const state = {
	goodsInfo:{}
}

const getters = {
	attrsList(state){
		return state.goodsInfo.attrsList
	},
	goodsList(state){
		return state.goodsInfo.goodsList
	},
	trademarkList(state){
		return state.goodsInfo.trademarkList
	},
	total(state){
		return state.goodsInfo.total
	}
}

export default {
	namespaced:true,
	actions,
	mutations,
	state,
	getters
}